/*
 * ---------------------------------------------------------------------
 * Copyright (c) 2014, 2015 All Right Reserved
 * This software is developed for study and improve coding skill ...
 *
 * Project:  Excellent Coding< EC >
 *
 * ecOSUtil.cpp
 * This program is file for OS depends Util functions implementation.
 *
 * Eamil:   epengao@126.com
 * Author:  Peter Gao
 * Version: Intial first version.
 * --------------------------------------------------------------------
 */

#include <time.h>
#include <stdlib.h>
#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif
#include "ecOSUtil.h"

namespace ec {

void ecGetSystemDate(EC_Date *pDate)
{
}

void ecSleep(EC_U32 nTime)
{
#ifdef _WIN32
    Sleep(nTime);
#else
    sleep(nTime);
#endif
}

EC_U32 ecGetSystemTime()
{
    EC_U32 nRet = 0;
#ifdef _WIN32
    nRet = GetTickCount();
#elif defined _LINUX
    struct timespec ts;
    clock_gettime(CLOCK_MONOTONIC, &ts);
    nRet = (ts.tv_sec * 1000 + ts.tv_nsec / 1000000);
#elif defined _IOS
    /* iOS systemtime */
#endif
    return nRet;
}

EC_U32 ecGetRandNumber()
{
    srand( (EC_U32)time(NULL) );
    return (EC_U32)rand();
}

} /*namespace ec*/